<form method=post action="test.jsp"> 把表单值提交到本页可以吗?
来源:百度知道 编辑:UC知道 时间:2024/05/18 19:19:38
test.jsp 内容如下:运行时出错。这一行出错:
onhand = Integer.parseInt(request.getParameter("txt_onhand"));
是不是不能把from提交给本页
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>add_account</title>
</head>
<body>
<form method="post" action="test.jsp">
<%
com.nettwn.finance.methodAccount method = new com.nettwn.finance.methodAccount();
com.nettwn.finance.accountInfo entity = new com.nettwn.finance.accountInfo();
int onhand = 0;
onhand = Integer.parseInt(request.getParameter("txt_onhand"));
是不是不能把from提交给本页
<%@ page language="java" contentType="text/html; charset=gb2312"
pageEncoding="gb2312"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title>add_account</title>
</head>
<body>
<form method="post" action="test.jsp">
<%
com.nettwn.finance.methodAccount method = new com.nettwn.finance.methodAccount();
com.nettwn.finance.accountInfo entity = new com.nettwn.finance.accountInfo();
int onhand = 0;
request.getParameter("txt_onhand")得到的是Object
而Integer.parseInt的参数应该是String
所以你强制转换一下就好了
request.getParameter("txt_onhand").toString()
或者(String)request.getParameter("txt_onhand")
补充一下你在条件判断if (request.getParameter("txt_name").toString() != "" && request.getParameter("txt_onhand").toString() !="" && request.getParameter("lst_type").toString() !="")
的时候还要判断一下request.getParameter("txt_name")是否为null。
可以的。
txt_onhand是null所以报错,""和null是不一样的
关于HTML <form> 里的method属性
<form name="form" method="post" onSubmit="return CheckForm(this);">
<form action="url" method=*>,*可以是什么?
网页设计关于<form method="post">
HTML中<form action="processingscript.php" method="post"> </form>是什么意思?麻烦各位老师说详细一点!
<FORM name=login onsubmit="return false;" action=/ method=post>
<form name="login" method="post" action="/LoginTransactor">
这个代码怎么来的(<form name="form1" method="post" action="Chkuser.asp">)或者解释
<form name="index" method="post" action="Check.asp" onsubmit="return checkData()">
<form action="register_2.asp?action=saveuser" method=POST name=adduser id=adduser>